| Total Complexity | 2 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { |
||
| 19 | |||
| 20 | @Controller('quotes') |
||
| 21 | @ApiUseTags('Billing') |
||
| 22 | @ApiBearerAuth() |
||
| 23 | @UseGuards(AuthGuard('bearer')) |
||
| 24 | export class CreateQuoteAction { |
||
| 25 | constructor( |
||
| 26 | @Inject('ICommandBus') |
||
| 27 | private readonly commandBus: ICommandBus, |
||
| 28 | @Inject('IQueryBus') |
||
| 29 | private readonly queryBus: IQueryBus |
||
| 30 | ) {} |
||
| 31 | |||
| 32 | @Post() |
||
| 33 | @ApiOperation({title: 'Create new quote'}) |
||
| 34 | public async index(@Body() quoteDto: QuoteDTO, @LoggedUser() user: User) { |
||
| 35 | try { |
||
| 36 | const {date, projectId, customerId, expiryDate} = quoteDto; |
||
| 37 | const id = await this.commandBus.execute( |
||
| 38 | new CreateQuoteCommand( |
||
| 39 | user, |
||
| 40 | new Date(date), |
||
| 41 | new Date(expiryDate), |
||
| 42 | customerId, |
||
| 43 | projectId |
||
| 44 | ) |
||
| 45 | ); |
||
| 46 | |||
| 47 | return id; |
||
| 48 | } catch (e) { |
||
| 49 | throw new BadRequestException(e.message); |
||
| 50 | } |
||
| 53 |